﻿<Window 
    x:Class="NoMvvm.Demo.Views.MainView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:nomvvm="clr-namespace:NoMvvm;assembly=NoMvvm"
    Title="NoMvvm Demo" Height="350" Width="525">

    <!--This converter just helps us bind a bool to a Visibility-->
    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="Converter" />
    </Window.Resources>

    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
            <nomvvm:EventToCommand Command="{Binding Refresh}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>

        <!--Refresh button-->
        <Button HorizontalAlignment="Left" Width="150" Height="30" Command="{Binding Refresh}">Refresh</Button>

        <!--List of our planets-->
        <ListView Grid.Row="1" ItemsSource="{Binding Planets}">
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Planet" DisplayMemberBinding="{Binding Name}" />
                    <GridViewColumn Header="Diameter" DisplayMemberBinding="{Binding Diameter}" />
                    <GridViewColumn Header="Info">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Button Command="{Binding Info}">Info</Button>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                </GridView>
            </ListView.View>
        </ListView>

        <!--Our busy indicator-->
        <TextBlock 
            Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center" 
            Text="Please Wait..." Visibility="{Binding IsBusy, Converter={StaticResource Converter}}" />

    </Grid>
</Window>
